/* eslint-disable max-lines */
import React from 'react';
import PropTypes from 'prop-types';
import {getDetail} from './api';
import styles from './style.css';
import {hasPermissions} from './utils';
import {PERMISSIONS} from './constants';
import {newOrUpdateOrderValidator} from './validator';
import {Form, Spin, Card, Button, Row, Col} from 'antd';
import {FORM_OPTIONS} from '../constants';
import FormItem from 'antd/lib/form/FormItem';
import TextInput from 'Shared/components/TextInput';
import {injectIntl, formatMessage, language} from './intl';
import Return from '../common/Return';
import WrappedDatePicker from '../common/WrappedDatePicker';
import WrappedSelect from '../common/WrappedSelect';
import DealerSelectPanel from '../common/DealerSelect/SelectEdit';
import RegionSelect from '../common/RegionSelect';
import {dealerExtendAuthorisedMethod, dealerExtendOnlineStatus} from '../Enum';
const authorisedMethodList = dealerExtendAuthorisedMethod.toList(language);
const onlineStatusList = dealerExtendOnlineStatus.toList(language);
class NewPanel extends React.PureComponent {
    state = {
        loading: false,
        data: {region: []},
        isSubmitting: false,
        hasOperat: false,
    }
    componentDidMount() {
        if(this.props.id)
            this.getDetailInfo();
    }
    componentWillUnmount() {
        this.isunmount = true;
    }
    getDetailInfo = () => {
        const id = this.props.id;
        this.setState({loading: true});
        getDetail(id)
            .then(res => {
                if(res.ok) {
                    const data = res.data;
                    const region = [];
                    if(data.areaId)
                        region.push(data.areaId);
                    if(data.countryId)
                        region.push(data.countryId);
                    if(data.provinceId)
                        region.push(data.provinceId);
                    if(data.cityId)
                        region.push(data.cityId);
                    data.region = region;
                    this.setState({
                        loading: false,
                        data: res.data
                    });
                } else
                    this.setState({
                        loading: false
                    });
            });
    }
    onSelectDealer = record => {
        this.setState({
            hasOperat: true,
            data: Object.assign({}, this.state.data, {
                dealerId: record.id,
                dealerCode: record.code,
                dealerName: record.name
            })
        });
    }
    onChange = (value, name) => {
        const data = Object.assign({}, this.state.data, {
            [name]: value
        });
        this.setState({
            data,
            hasOperat: true
        });
    }
    onSubmit = () => {
        const data = this.state.data;
        const isValid = newOrUpdateOrderValidator(data);
        if(!isValid) {
            this.setState({
                validate: true
            });
            return;
        }
        this.setState({loading: true});
        this.props.onSubmit(data).then(res => {
            if(res.success)
                this.props.successReturn();
            if(!this.isunmount)
                this.setState({loading: false});
        });
    };
    render() {
        const {data, isSubmitting} = this.state;
        const regionSelectDefaultOption = {
            areaId: data.areaId,
            areaName: data.areaName,
            countryId: data.countryId,
            countryName: data.countryName,
            provinceId: data.provinceId,
            provinceName: data.provinceName,
            cityId: data.cityId,
            cityName: data.cityName
        };
        const dealerInfo = data.dealerId ? {
            id: data.dealerId,
            code: data.dealerCode,
            name: data.dealerName
        } : null;
        const validateCode = !data.code && this.state.validate ? 'error' : null;
        const validateName = !data.name && this.state.validate ? 'error' : null;
        const validateDealerCode = !data.dealerCode && this.state.validate ? 'error' : null;
        const submitable = !hasPermissions(PERMISSIONS.add, this.props.permission) || !hasPermissions(PERMISSIONS.update, this.props.permission);
        return (
            <div className="form-standard">
                <Spin spinning={this.state.loading}>
                    <Form>
                        <Card title={formatMessage({
                            id: 'newPanel.column.dealer',
                            defaultMessage: '经销商信息'
                        })}>
                            <Row>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.dealer',
                                        defaultMessage: '所属总代'
                                    })} {...FORM_OPTIONS.item}
                                    validateStatus={validateDealerCode}
                                    required>
                                        {this.props.id ? `(${data.dealerCode})${data.dealerName}`
                                            : <DealerSelectPanel
                                                value={dealerInfo}
                                                onSelect={this.onSelectDealer} />}
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.Code',
                                        defaultMessage: '编号'
                                    })} {...FORM_OPTIONS.item}
                                    validateStatus={validateCode}
                                    required>
                                        <TextInput
                                            name="code"
                                            value={data.code}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.Name',
                                        defaultMessage: '名称'
                                    })} {...FORM_OPTIONS.item}
                                    validateStatus={validateName}
                                    required>
                                        <TextInput
                                            name="name"
                                            value={data.name}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.shortCode',
                                        defaultMessage: '简码'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="shortCode"
                                            value={data.shortCode}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.shortName',
                                        defaultMessage: '简称'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="shortName"
                                            value={data.shortName}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.regionId',
                                        defaultMessage: '国省市'
                                    })}{...FORM_OPTIONS.item}>
                                        <RegionSelect
                                            name="region"
                                            defaultOption={regionSelectDefaultOption}
                                            value={data.region}
                                            onChange={this.onChange}
                                            changeOnSelect={true} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.contactName',
                                        defaultMessage: '联系人姓名'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="contactName"
                                            value={data.contactName}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.contactPhone',
                                        defaultMessage: '联系人电话'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="contactPhone"
                                            value={data.contactPhone}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.fax',
                                        defaultMessage: '传真'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="fax"
                                            value={data.fax}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.email',
                                        defaultMessage: '电子邮箱'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="email"
                                            value={data.email}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.address',
                                        defaultMessage: '联系地址'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="address"
                                            value={data.address}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.zipCode',
                                        defaultMessage: '邮政编码'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="zipCode"
                                            value={data.zipCode}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                            </Row>
                        </Card>
                        <Card title={formatMessage({
                            id: 'newPanel.column.dealerExtend',
                            defaultMessage: '扩展信息'
                        })}>
                            <Row>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.buildDate',
                                        defaultMessage: '建店日期'
                                    })} {...FORM_OPTIONS.item}>
                                        <WrappedDatePicker
                                            name="buildDate"
                                            value={data.buildDate}
                                            onChange={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.openDate',
                                        defaultMessage: '开业日期'
                                    })} {...FORM_OPTIONS.item}>
                                        <WrappedDatePicker
                                            name="openDate"
                                            value={data.openDate}
                                            onChange={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.updatedDate',
                                        defaultMessage: '更新日期'
                                    })} {...FORM_OPTIONS.item}>
                                        <WrappedDatePicker
                                            name="updatedDate"
                                            value={data.updatedDate}
                                            onChange={this.onChange} />
                                    </FormItem>
                                </Col>
                            </Row>
                            <Row>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.juridicalPerson',
                                        defaultMessage: '法人'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="juridicalPerson"
                                            value={data.juridicalPerson}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.juridicalPersonPhone',
                                        defaultMessage: '法人电话'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="juridicalPersonPhone"
                                            value={data.juridicalPersonPhone}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.juridicalPersonEmail',
                                        defaultMessage: '法人Email'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="juridicalPersonEmail"
                                            value={data.juridicalPersonEmail}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.generalManager',
                                        defaultMessage: '总经理'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="generalManager"
                                            value={data.generalManager}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.generalManagerPhone',
                                        defaultMessage: '总经理电话'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="generalManagerPhone"
                                            value={data.generalManagerPhone}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.generalManagerEmail',
                                        defaultMessage: '总经理Email'
                                    })}{...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="generalManagerEmail"
                                            value={data.generalManagerEmail}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.salesDirector',
                                        defaultMessage: '销售总监'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="salesDirector"
                                            value={data.salesDirector}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.salesDirectorPhone',
                                        defaultMessage: '销售总监电话'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="salesDirectorPhone"
                                            value={data.salesDirectorPhone}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.salesDirectorEmail',
                                        defaultMessage: '销售总监Email'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="salesDirectorEmail"
                                            value={data.salesDirectorEmail}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.serviceDirector',
                                        defaultMessage: '服务总监'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="serviceDirector"
                                            value={data.serviceDirector}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.serviceDirectorPhone',
                                        defaultMessage: '服务总监电话'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="serviceDirectorPhone"
                                            value={data.serviceDirectorPhone}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.serviceDirectorEmail',
                                        defaultMessage: '服务总监Email'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="serviceDirectorEmail"
                                            value={data.serviceDirectorEmail}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.marketDirector',
                                        defaultMessage: '市场总监'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="marketDirector"
                                            value={data.marketDirector}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.marketDirectorPhone',
                                        defaultMessage: '市场总监电话'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="marketDirectorPhone"
                                            value={data.marketDirectorPhone}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.marketDirectorEmail',
                                        defaultMessage: '市场总监Email'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="marketDirectorEmail"
                                            value={data.marketDirectorEmail}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.financialController',
                                        defaultMessage: '财务总监'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="financialController"
                                            value={data.financialController}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.financialControllerPhone',
                                        defaultMessage: '财务总监电话'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="financialControllerPhone"
                                            value={data.financialControllerPhone}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.financialControllerEmail',
                                        defaultMessage: '财务总监Email'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="financialControllerEmail"
                                            value={data.financialControllerEmail}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.salesInterfacePerson',
                                        defaultMessage: '销售接口录入人'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="salesInterfacePerson"
                                            value={data.salesInterfacePerson}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem className={styles.multiLabel} label={formatMessage({
                                        id: 'newPanel.operation.salesInterfacePhone',
                                        defaultMessage: '销售接口录入人电话'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="salesInterfacePhone"
                                            value={data.salesInterfacePhone}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem className={styles.multiLabel} label={formatMessage({
                                        id: 'newPanel.operation.salesInterfaceEmail',
                                        defaultMessage: '销售接口录入人Email'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="salesInterfaceEmail"
                                            value={data.salesInterfaceEmail}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.serviceInterfacePerson',
                                        defaultMessage: '服务接口录入人'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="serviceInterfacePerson"
                                            value={data.serviceInterfacePerson}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem className={styles.multiLabel} label={formatMessage({
                                        id: 'newPanel.operation.serviceInterfacePhone',
                                        defaultMessage: '服务接口录入人电话'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="serviceInterfacePhone"
                                            value={data.serviceInterfacePhone}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem className={styles.multiLabel} label={formatMessage({
                                        id: 'newPanel.operation.serviceInterfaceEmail',
                                        defaultMessage: '服务接口录入人Email'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="serviceInterfaceEmail"
                                            value={data.serviceInterfaceEmail}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem className={styles.multiLabel} label={formatMessage({
                                        id: 'newPanel.operation.incorporatedDate',
                                        defaultMessage: '公司成立日期'
                                    })} {...FORM_OPTIONS.item}>
                                        <WrappedDatePicker
                                            name="incorporatedDate"
                                            value={data.incorporatedDate}
                                            onChange={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem className={styles.multiLabel} label={formatMessage({
                                        id: 'newPanel.operation.startTime',
                                        defaultMessage: '授权经营奇瑞起始时时间'
                                    })} {...FORM_OPTIONS.item}>
                                        <WrappedDatePicker
                                            name="startTime"
                                            value={data.startTime}
                                            onChange={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.arrivedAddress',
                                        defaultMessage: '收货港'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="arrivedAddress"
                                            value={data.arrivedAddress}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                            </Row>
                            <Row>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.authorisedMethod',
                                        defaultMessage: '授权方式'
                                    })} {...FORM_OPTIONS.item}>
                                        <WrappedSelect
                                            allowClear
                                            name="authorisedMethod"
                                            options={authorisedMethodList}
                                            value={data.authorisedMethod}
                                            onChange={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.authorisedArea',
                                        defaultMessage: '授权区域'
                                    })} {...FORM_OPTIONS.item}>
                                        <TextInput
                                            name="authorisedArea"
                                            value={data.authorisedArea}
                                            onBlur={this.onChange} />
                                    </FormItem>
                                </Col>
                                <Col {...FORM_OPTIONS.col}>
                                    <FormItem label={formatMessage({
                                        id: 'newPanel.operation.onlineStatus',
                                        defaultMessage: '上线状态'
                                    })} {...FORM_OPTIONS.item}>
                                        <WrappedSelect
                                            allowClear
                                            name="onlineStatus"
                                            options={onlineStatusList}
                                            value={data.onlineStatus}
                                            onChange={this.onChange} />
                                    </FormItem>
                                </Col>
                            </Row>
                        </Card>
                    </Form>
                    <Card className={styles.optionBtn}>
                        <Button
                            type="primary"
                            onClick={this.onSubmit}
                            disabled={!submitable}
                            loading={isSubmitting}>
                            {formatMessage({
                                id: 'newPanel.operation.onSave',
                                defaultMessage: '保存'
                            })}
                        </Button>
                    </Card>
                </Spin>
                <div className="page-toolbar">
                    <Return
                        disabled={this.state.loading}
                        showWarning={this.state.hasOperat}
                        onConfirm={this.props.onCancel} />
                </div>
            </div>
        );
    }
}

NewPanel.propTypes = {
    permission: PropTypes.array.isRequired,
    successReturn: PropTypes.func.isRequired,
    onCancel: PropTypes.func.isRequired,
    onSubmit: PropTypes.func.isRequired,
    history: PropTypes.object,
};

import {connect} from 'react-redux';
import routes from './routes';
import {
    tableSearch,
    onSubmit
} from './actions';
import selectorFactory from 'Shared/utils/immutableToJsSelectorFactory';
const getPermissions = selectorFactory(['page', 'domainData', 'permission', 'data']);
const mapStateToProps = state => ({
    permission: getPermissions(state),
});

const mapDispatchToProps = (dispatch, props) => ({
    onSubmit: data => dispatch(onSubmit(data)),
    successReturn: () => {
        dispatch(tableSearch());
        props.history.push(routes.query.url());
    },
    onCancel: () => {
        props.history.push(routes.query.url());
    },
});
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(NewPanel));
